/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:张熳
 * Date:2025-10-05
 * Time:21:05
 */
public class Test {
    public static void main(String[] args) {
        MySingleList list1 = new MySingleList();
        list1.addLast(10);
        list1.addLast(11);
        list1.addLast(12);
        list1.addLast(13);
        list1.addLast(14);
        list1.display();

        list1.clear();
        //list1.display();//还剩下第一个元素没有清除  会打印10
        list1.display();
    }
    public static void main5(String[] args) {
        MySingleList list = new MySingleList();
        list.addLast(22);
        list.addLast(22);
        list.addLast(3);
        list.addLast(22);
        list.addLast(5);

        list.removeAllKey(22);
        list.display();
    }
    public static void main4(String[] args) {
        MySingleList list = new MySingleList();
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        list.addLast(5);
        list.display();//1 2 3 4 5

        list.remove(3);
        list.display();//1 2 4 5
    }
    public static void main3(String[] args) {
        //头插
        MySingleList list = new MySingleList();
        list.addFirst(10);
        list.addFirst(11);
        list.addFirst(12);
        list.addFirst(13);
        list.addFirst(14);

        list.display();//14 13 12 11 10

        //尾插
        MySingleList list1 = new MySingleList();
        list1.addLast(10);
        list1.addLast(11);
        list1.addLast(12);
        list1.addLast(13);
        list1.addLast(14);

        list1.display();//10 11 12 13 14

        //任意位置插入
        list1.addIndex(0,199);
        list1.addIndex(3,399);
        list1.addIndex(list1.size(), 999);

        list1.display();//199 10 11 399 12 13 14 999
    }
    public static void main2(String[] args) {
        //测试打印
        MySingleList list = new MySingleList();
        list.createList();
        list.display();//12 23 34 45 56
        //获取单链表的长度
        System.out.println(list.size());//5  cur != null——遍历到单链表的尾节点结束
        //System.out.println(list.size());//4  cur.next != null——遍历到单链表的尾节点的前一个节点结束

        System.out.println(list.contains(34));

        list.addFirst(99);
        list.display();//99 12 23 34 45 56

        list.addLast(999);
        list.display();//99 12 23 34 45 56 999
    }
    public static void main1(String[] args) {
        ISingleList list = new MySingleList();
        //list.createList();
        list.display();
    }
}
